package com.cdm.persistence;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Table;

/**
 * CdmLicense entity.
 * 
 * @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "cdm_license", catalog = "cdm", uniqueConstraints = {})
public class License implements java.io.Serializable {

	// Fields

	private Long licenseId;
	private String version = "001";
	private LicenseTemplate licenseTemplate;
	private Long spid;

	public static void main(String[] args) {
		LicenseTemplate t = EntityManagerHelper.getEntityManager().find(LicenseTemplate.class, 3l);
		License l = new License();
		l.setLicenseId(01l);
		l.setLicenseTemplate(t);
		l.setSpid(999l);

		EntityManagerHelper.beginTransaction();
		EntityManagerHelper.getEntityManager().persist(l);
		EntityManagerHelper.commit();

	}

	// Constructors

	/** default constructor */
	public License() {
	}

	/** full constructor */
	public License(Long licenseId, String version, LicenseTemplate licenseTemplate, Long spid) {
		this.licenseId = licenseId;
		this.version = version;
		this.licenseTemplate = licenseTemplate;
		this.spid = spid;
	}

	// Property accessors
	@Id
	@Column(name = "license_id", unique = true, nullable = false, insertable = true, updatable = true)
	public Long getLicenseId() {
		return this.licenseId;
	}

	public void setLicenseId(Long licenseId) {
		this.licenseId = licenseId;
	}

	@Column(name = "version", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public String getVersion() {
		return this.version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	@Column(name = "license_template", unique = false, nullable = false, insertable = true, updatable = true)
	@JoinColumn(name = "licnese_template", referencedColumnName = "license_template_id")
	public LicenseTemplate getLicenseTemplate() {
		return this.licenseTemplate;
	}

	public void setLicenseTemplate(LicenseTemplate licenseTemplate) {
		this.licenseTemplate = licenseTemplate;
	}

	@Column(name = "spid", unique = false, nullable = false, insertable = true, updatable = true)
	public Long getSpid() {
		return this.spid;
	}

	public void setSpid(Long spid) {
		this.spid = spid;
	}

}